package com.zxy.permission_stu.controller;


import com.zxy.permission_stu.config.AjaxResult;
import com.zxy.permission_stu.entity.Classes;
import com.zxy.permission_stu.service.IClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器 gie提交展现现场v
 * </p>
 *
 * @author lenovo
 * @since 2021-11-30
 */
@RestController
@RequestMapping("/classes")
public class ClassesController {

    @Autowired
    private IClassesService classesService;
    @Autowired
    private RedisTemplate redisTemplate;


    @RequestMapping("getClasses")
    public AjaxResult getClasses(){
        /*String key = "classes";
        Boolean hasKey = redisTemplate.hasKey(key);
        List<Classes> list = null;
        if(hasKey){
            list = redisTemplate.opsForList().range(key,0,-1);
        }else{
            list = classesService.list();
            redisTemplate.opsForList().leftPushAll(key,list);
        }*/
        List<Classes> list = classesService.listAll();
        return AjaxResult.ok(list);
    }
}
